package xuperchain

import (
	"fmt"

	"github.com/xuperchain/xuper-sdk-go/v2/account"
	"github.com/xuperchain/xuper-sdk-go/v2/xuper"
)

func DeleteFile() (result string) {

	account, err := account.GetAccountFromFile(path, pwd)
	if err != nil {
		fmt.Printf("GetAccountFromFile err: %v\n", err)
		panic(err)
	}

	err = account.SetContractAccount(contractAccount)
	if err != nil {
		panic(err)
	}

	xchainClient, err := xuper.New(nodeAddress)
	if err != nil {
		panic(err)
	}

	contractName := "xc_filestorage8"

	argsDeleteFile := map[string]string{"_name": "papername1"}

	txDeleteFile, err := xchainClient.InvokeEVMContract(account, contractName, "deleteFile", argsDeleteFile)
	if err != nil {
		panic(err)
	}
	fmt.Printf("deleteFile success! TXID: %x\n", txDeleteFile.Tx.Txid)

	return "success"
}
